<?php if ( ! defined('BASEPATH')) exit ('No direct script access allowed');
//require("class.phpmailer.php");

class mailer extends CI_Controller {
	
	function index() {
		$this -> load -> library('phpmailer');
		$mail = $this -> phpmailer;
		
		//$mail = new PHPMailer();
		$mail->IsSMTP();                 // 启用SMTP
		$mail->SMTPSecure = "tls";                 // sets the prefix to the servier
		$mail->SMTPAuth = true;                  //开启SMTP认证
		
		//$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
		//$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
		//$mail->Username = "colinyan@gmail.com";            // SMTP用户名
		//$mail->Password = "C0l1ny12";                // SMTP密码

		$mail->Host       = "cooleosoftnet.ipage.com";      // sets GMAIL as the SMTP server
		$mail->Port       = 587;                   // set the SMTP port for the GMAIL server
		$mail->Username = "tester@cooleosoft.net";            // SMTP用户名
		$mail->Password = "AMY_jiang123";                // SMTP密码
		
		
		$mail->From = "colinyan@gmail.com";            //发件人地址
		$mail->FromName = "test Mailer";              //发件人
		$mail->AddAddress("colinyan@hotmail.com", "CY"); //添加收件人
		$mail->AddAddress("colinyan@gmail.com");
		$mail->AddReplyTo("colinyan@gmail.com", "Information");    //回复地址
		$mail->WordWrap = 50;                    //设置每行字符长度
		/** 附件设置
		$mail->AddAttachment("/var/tmp/file.tar.gz");        // 添加附件
		$mail->AddAttachment("/tmp/image.jpg", "new.jpg");   // 添加附件,并指定名称
		*/
		$mail->IsHTML(true);                 // 是否HTML格式邮件
		$mail->Subject = "Here is the subject";          //邮件主题
		$mail->Body    = "This is the HTML message body <b>in bold!</b>";        //邮件内容
		$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //邮件正文不支持HTML的备用显示
		if(!$mail->Send())
			{
				echo "Message could not be sent. <p>";
				echo "Mailer Error: " . $mail->ErrorInfo;
				exit;
			}
			echo "Message has been sent";
	}	
}